package com.mxx.common.netty.ws;


import com.mxx.common.conv.JacksonConverter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.websocketx.WebSocketFrame;

/**
 * @Auther: Mr. Zeng
 * @Date: 2020/8/10 10:27
 * @Description: 暂无描述
 */
public class DefaultWebsocketFactory implements WebsocketFactory {

    private JacksonConverter jacksonConverter;

    public DefaultWebsocketFactory(JacksonConverter jacksonConverter) {
        this.jacksonConverter = jacksonConverter;
    }

    @Override
    public NettyWebsocketRequest createRequest(ChannelHandlerContext context, WebSocketFrame webSocketFrame) {
        return new DefaultNettyWebsocketRequest(context, webSocketFrame, message(), jacksonConverter);
    }

    @Override
    public Class<? extends NettyWebsocketMessage> message() {
        return DefaultNettyWebsocketMessage.class;
    }
}
